/*
 * CTCPReader.cpp
 *
 *  Created on: 06.03.2012
 *      Author: caffeine
 */

#include "CTCPReader.h"
#include <lampe/exception/Base.h>

namespace lampe{
namespace stream{
namespace tcp{

bool CTCPReader::eof(){
	return isEnd;
}

u32 CTCPReader::read(void* buffer, u32 size){
	if (isEnd)
		return 0;
	if (!signal)
		return do_recv(sock,buffer,size);
	int readed=do_recv(sock,buffer,size);
	if (readed!=(int)size)
		isEnd=true;
	//GEN_ERROR("Can't read data: size of readed min of data size");
	return readed;
}

CTCPReader::CTCPReader(SOCKET s,bool sing){
	sock=s;
	signal=s;
	isEnd=false;
}

CTCPReader::~CTCPReader(){
}

}//namespace tcp
}//namespace stream
}//namespace lampe

